package com.wuliupai.delivery.wuliupaidelivery.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wuliupai.delivery.wuliupaidelivery.R;
import com.wuliupai.delivery.wuliupaidelivery.bean2.warehouse.OpenCity;

import java.util.ArrayList;
import java.util.List;

/**
 * Descriptions：仓库所在区域列表 Adapter
 * <p>
 * Author：ChenME
 * Date：2017/3/16
 * Email：ibelieve1210@163.com
 */
public class WarehouseAreaListAdapter extends BaseAdapter {

    private Context mContext;
    private List<OpenCity> dataList = new ArrayList<>();

    public WarehouseAreaListAdapter(Context mContext, List<OpenCity> dataList) {
        this.mContext = mContext;
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return null == dataList ? 0 : dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vHolder;
        if (null == convertView) {
            vHolder = new ViewHolder();
            convertView = View.inflate(mContext, R.layout.item_warehouse_area_lv, null);
            vHolder.tv_warehouseAreaName = (TextView) convertView.findViewById(R.id.tv_warehouseAreaName);
            convertView.setTag(vHolder);
        } else {
            vHolder = (ViewHolder) convertView.getTag();
        }

        OpenCity openCity = dataList.get(position);
        vHolder.tv_warehouseAreaName.setText(openCity.getcName());

        return convertView;
    }

    class ViewHolder {
        private TextView tv_warehouseAreaName;
    }
}